﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Libero.FusionCharts;
using System.Data;

namespace WebApplication1
{
    public partial class exemplo_SS_datasource : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // Create a chart
            Pie2DChart oChart = new Pie2DChart();

            // Set properties
            oChart.Background.BgColor = "ffffff";
            oChart.Background.BgAlpha = 50;
            oChart.ChartTitles.Caption = "Top seller (%)";
            oChart.ChartTitles.SubCaption = "November";

            // Set a template
            oChart.Template = new Libero.FusionCharts.Template.OfficeTemplate();

            // Set data
            DataTable dtSample = GetSalesDataTable();
            oChart.DataSource = dtSample;
            oChart.DataTextField = "SallesmanName";
            oChart.DataValueField = "PercentTotalSell";

            // Link the WebControl and the Chart
            chtTopSalles.ShowChart(oChart);
        }

        private DataTable GetSalesDataTable()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("SallesmanName", typeof(String));
            dt.Columns.Add("PercentTotalSell", typeof(int));


            dt.Rows.Add("Alan", 9);
            dt.Rows.Add("Tom", 15);
            dt.Rows.Add("Tete", 25);
            dt.Rows.Add("Ana", 51);

            return dt;
        }

    }
}